package pi.server.gui;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class ServerGUI{
	JFrame frame;
	JScrollPane scrollPane;
	public JTextArea textArea;

	public ServerGUI(){
		frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLayout(null);
		frame.setResizable(false);
		frame.setVisible(true);
		frame.setBounds(20, 20, 600, 480);
		frame.setTitle("Projeto Integrador - Server");

		textArea = new JTextArea();
		textArea.setText("Server: Server Gui Created!");
		
		scrollPane = new JScrollPane(textArea);		
		scrollPane.setBounds(5, 5, frame.getWidth()-15, frame.getHeight()-37);
		
		frame.add(scrollPane);
	}
	
	public void SetTextClient(String clientName, String text){
		textArea.setText(textArea.getText() + "\n" + "Client: " + clientName + ": " + text);
		textArea.setCaretPosition(textArea.getText().length());
	}
	
	public void SetTextServer(String text){
		textArea.setText(textArea.getText() + "\n" + "Server: " + text);
		textArea.setCaretPosition(textArea.getText().length());
	}
	
	public void SetText(String text){
		textArea.setText(textArea.getText() + "\n" + text);
		textArea.setCaretPosition(textArea.getText().length());
	}
}
